home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1999 January / PC Plus Super CD No55a (PCP-147A-1-99) (Disc 1) (1998).iso / linux / developers / visualtcl / windows / vtcl / lib / bind.tcl < prev    next >
Encoding:
Text File  |  1997-05-27  |  11.5 KB  |  292 lines

  1. ##############################################################################
  2. # $Id: bind.tcl,v 1.4 1997/05/28 02:34:03 stewart Exp $
  3. #
  4. # bind.tcl - procedures to control widget bindings
  5. #
  6. # Copyright (C) 1996-1997 Stewart Allen
  7. #
  8. # This program is free software; you can redistribute it and/or
  9. # modify it under the terms of the GNU General Public License
  10. # as published by the Free Software Foundation; either version 2
  11. # of the License, or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. ##############################################################################
  23. #
  24.  
  25. proc vTclWindow(post).vTcl.bind {args} {
  26.     vTcl:setup_vTcl:bind .vTcl.bind
  27. }
  28.  
  29. proc vTcl:add_bind {} {
  30.     global vTcl
  31.     bind $vTcl(w,widget) $vTcl(bind,event) [string trim [.vTcl.bind.fra9.fra16.tex21 get 0.0 end] "\n"]
  32.     vTcl:get_bind $vTcl(w,widget)
  33. }
  34.  
  35. proc vTcl:delete_bind {} {
  36.     global vTcl
  37.     if {$vTcl(bind,event) != ""} {
  38.         bind $vTcl(w,widget) $vTcl(bind,event) ""
  39.     }
  40.     vTcl:get_bind $vTcl(w,widget)
  41. }
  42.  
  43. proc vTcl:get_bind {target} {
  44.     global vTcl
  45.     if {[winfo exists .vTcl.bind] == 1} {
  46.         set vTcl(bind,list) [bind $target]
  47.         .vTcl.bind.fra9.ent14 delete 0 end
  48.         .vTcl.bind.fra9.fra16.tex21 delete 0.0 end
  49.         .vTcl.bind.fra9.fra9.lis10 delete 0 end
  50.         foreach i $vTcl(bind,list) {
  51.             .vTcl.bind.fra9.fra9.lis10 insert end $i
  52.         }
  53.         set vTcl(bind,tags) $vTcl(bindtags,$target)
  54.         set vTcl(bind,event) ""
  55.     }
  56. }
  57.  
  58. proc vTcl:select_bind {} {
  59.     global vTcl
  60.     .vTcl.bind.fra9.fra16.tex21 delete 0.0 end
  61.     set listnum [.vTcl.bind.fra9.fra9.lis10 curselection]
  62.     if {$listnum != ""} {
  63.         set vTcl(bind,event) [.vTcl.bind.fra9.fra9.lis10 get $listnum]
  64.         .vTcl.bind.fra9.fra16.tex21 insert end [bind $vTcl(w,widget) $vTcl(bind,event)]
  65.     }
  66. }
  67.  
  68. proc vTcl:update_bind {} {
  69.     global vTcl
  70.     set listnum [.vTcl.bind.fra9.fra9.lis10 curselection]
  71.     if {$listnum != ""} {
  72.         bind $vTcl(w,widget) $vTcl(bind,event) [string trim [.vTcl.bind.fra9.fra16.tex21 get 0.0 end] "\n"]
  73.     }
  74.     vTcl:get_bind $vTcl(w,widget)
  75. }
  76.  
  77. proc vTclWindow.vTcl.bind {args} {
  78.     set base .vTcl.bind
  79.     if {[winfo exists .vTcl.bind]} {
  80.         wm deiconify .vTcl.bind; return
  81.     }
  82.     toplevel .vTcl.bind -class vTcl
  83.     wm transient .vTcl.bind .vTcl
  84.     wm focusmodel .vTcl.bind passive
  85.     wm geometry .vTcl.bind 416x351+79+162
  86.     wm maxsize .vTcl.bind 1137 870
  87.     wm minsize .vTcl.bind 415 350
  88.     wm overrideredirect .vTcl.bind 0
  89.     wm resizable .vTcl.bind 0 0
  90.     wm deiconify .vTcl.bind
  91.     wm title .vTcl.bind "Widget Bindings"
  92.     frame .vTcl.bind.fra9 \
  93.         -borderwidth 1 -height 30 -relief sunken -width 30 
  94.     place .vTcl.bind.fra9 \
  95.         -x 5 -relx 0 -y 5 -rely 0 -width 405 -relwidth {} -height 340 \
  96.         -relheight {} -anchor nw -bordermode ignore 
  97.     frame .vTcl.bind.fra9.fra12 \
  98.         -borderwidth 1 -height 30 -relief sunken -width 30 
  99.     place .vTcl.bind.fra9.fra12 \
  100.         -x 5 -relx 0 -y 190 -rely 0 -width 395 -relwidth {} -height 30 \
  101.         -relheight {} -anchor nw -bordermode ignore 
  102.     button .vTcl.bind.fra9.fra12.but13 \
  103.         -command vTcl:add_bind \
  104.          \
  105.         -highlightthickness 0 -padx 9 -pady 3 -text Add -width 5 
  106.     pack .vTcl.bind.fra9.fra12.but13 \
  107.         -in .vTcl.bind.fra9.fra12 -anchor center -expand 1 -fill both \
  108.         -ipadx 0 -ipady 0 -padx 2 -pady 2 -side left 
  109.     button .vTcl.bind.fra9.fra12.but14 \
  110.         -command vTcl:update_bind \
  111.          \
  112.         -highlightthickness 0 -padx 9 -pady 3 -text Update -width 5 
  113.     pack .vTcl.bind.fra9.fra12.but14 \
  114.         -in .vTcl.bind.fra9.fra12 -anchor center -expand 1 -fill both \
  115.         -ipadx 0 -ipady 0 -padx 2 -pady 2 -side left 
  116.     button .vTcl.bind.fra9.fra12.but15 \
  117.         -command vTcl:delete_bind \
  118.          \
  119.         -highlightthickness 0 -padx 9 -pady 3 -text Delete -width 5 
  120.     pack .vTcl.bind.fra9.fra12.but15 \
  121.         -in .vTcl.bind.fra9.fra12 -anchor center -expand 1 -fill both \
  122.         -ipadx 0 -ipady 0 -padx 2 -pady 2 -side left 
  123.     button .vTcl.bind.fra9.fra12.but16 \
  124.         -command {destroy .vTcl.bind} \
  125.         -highlightthickness 0 -padx 9 -pady 3 -text Done -width 5 
  126.     pack .vTcl.bind.fra9.fra12.but16 \
  127.         -in .vTcl.bind.fra9.fra12 -anchor center -expand 1 -fill both \
  128.         -ipadx 0 -ipady 0 -padx 2 -pady 2 -side left 
  129.     frame .vTcl.bind.fra9.fra9 \
  130.         -height 30 -width 30 
  131.     place .vTcl.bind.fra9.fra9 \
  132.         -x 5 -relx 0 -y 225 -rely 0 -width 395 -relwidth {} -height 110 \
  133.         -relheight {} -anchor nw -bordermode ignore 
  134.     listbox .vTcl.bind.fra9.fra9.lis10 \
  135.          \
  136.         -highlightthickness 0 \
  137.         -yscrollcommand {.vTcl.bind.fra9.fra9.scr11 set} 
  138.     pack .vTcl.bind.fra9.fra9.lis10 \
  139.         -in .vTcl.bind.fra9.fra9 -anchor center -expand 1 -fill both -ipadx 0 \
  140.         -ipady 0 -padx 0 -pady 0 -side left 
  141.     bind .vTcl.bind.fra9.fra9.lis10 <Double-Button-1> {
  142.        vTcl:select_bind
  143.     }
  144.     scrollbar .vTcl.bind.fra9.fra9.scr11 \
  145.         -borderwidth 1 -command {.vTcl.bind.fra9.fra9.lis10 yview} \
  146.         -highlightthickness 0
  147.     pack .vTcl.bind.fra9.fra9.scr11 \
  148.         -in .vTcl.bind.fra9.fra9 -anchor center -expand 0 -fill y -ipadx 0 \
  149.         -ipady 0 -padx 0 -pady 0 -side right 
  150.     entry .vTcl.bind.fra9.ent14 \
  151.          \
  152.         -highlightthickness 0 -textvariable vTcl(bind,scratch) 
  153.     bind .vTcl.bind.fra9.ent14 <KeyPress> {
  154.         append vTcl(bind,event) "<Key-%K>"
  155.     }
  156.     place .vTcl.bind.fra9.ent14 \
  157.         -x 75 -relx 0 -y 5 -rely 0 -width 60 -relwidth {} -height 20 \
  158.         -relheight {} -anchor nw -bordermode ignore 
  159.     entry .vTcl.bind.fra9.ent15 \
  160.          \
  161.         -highlightthickness 0 -textvariable vTcl(bind,event) 
  162.     place .vTcl.bind.fra9.ent15 \
  163.         -x 60 -relx 0 -y 143 -rely 0 -width 340 -relwidth {} -height 20 \
  164.         -relheight {} -anchor nw -bordermode ignore 
  165.     frame .vTcl.bind.fra9.fra16 \
  166.         -height 30 -width 30 
  167.     place .vTcl.bind.fra9.fra16 \
  168.         -x 5 -relx 0 -y 50 -rely 0 -width 395 -relwidth {} -height 89 \
  169.         -relheight {} -anchor nw -bordermode ignore 
  170.     scrollbar .vTcl.bind.fra9.fra16.scr20 \
  171.         -borderwidth 1 -command {.vTcl.bind.fra9.fra16.tex21 yview} \
  172.         -highlightthickness 0
  173.     pack .vTcl.bind.fra9.fra16.scr20 \
  174.         -in .vTcl.bind.fra9.fra16 -anchor center -expand 0 -fill y -ipadx 0 \
  175.         -ipady 0 -padx 0 -pady 0 -side right 
  176.     text .vTcl.bind.fra9.fra16.tex21 \
  177.          \
  178.         -highlightthickness 0 \
  179.         -yscrollcommand {.vTcl.bind.fra9.fra16.scr20 set} 
  180.     pack .vTcl.bind.fra9.fra16.tex21 \
  181.         -in .vTcl.bind.fra9.fra16 -anchor center -expand 1 -fill both \
  182.         -ipadx 0 -ipady 0 -padx 0 -pady 0 -side top 
  183.     label .vTcl.bind.fra9.lab23 \
  184.          \
  185.         -relief groove -text {Type -->} 
  186.     place .vTcl.bind.fra9.lab23 \
  187.         -x 5 -relx 0 -y 5 -rely 0 -width 65 -relwidth {} -height 20 \
  188.         -relheight {} -anchor nw -bordermode ignore 
  189.     label .vTcl.bind.fra9.lab24 \
  190.          \
  191.         -relief groove -text Command 
  192.     place .vTcl.bind.fra9.lab24 \
  193.         -x 5 -relx 0 -y 28 -rely 0 -width 395 -relwidth {} -height 20 \
  194.         -relheight {} -anchor nw -bordermode ignore 
  195.     label .vTcl.bind.fra9.lab25 \
  196.          \
  197.         -relief groove -text Event 
  198.     place .vTcl.bind.fra9.lab25 \
  199.         -x 5 -relx 0 -y 143 -rely 0 -width 50 -relwidth {} -height 20 \
  200.         -relheight {} -anchor nw -bordermode ignore 
  201.     label .vTcl.bind.fra9.lab26 \
  202.          \
  203.         -relief groove -text Tags 
  204.     place .vTcl.bind.fra9.lab26 \
  205.         -x 5 -relx 0 -y 166 -rely 0 -width 50 -relwidth {} -height 20 \
  206.         -relheight {} -anchor nw -bordermode ignore 
  207.     entry .vTcl.bind.fra9.ent27 \
  208.          \
  209.         -highlightthickness 0 -textvariable vTcl(bind,tags) 
  210.     place .vTcl.bind.fra9.ent27 \
  211.         -x 60 -relx 0 -y 166 -rely 0 -width 340 -relwidth {} -height 20 \
  212.         -relheight {} -anchor nw -bordermode ignore 
  213.     menubutton .vTcl.bind.fra9.men1 \
  214.         -borderwidth 1 \
  215.          \
  216.         -menu .vTcl.bind.fra9.men1.m -padx 5 -pady 4 -relief raised \
  217.         -text Mouse 
  218.     place .vTcl.bind.fra9.men1 \
  219.         -x 145 -relx 0 -y 5 -rely 0 -width 60 -relwidth {} -height 20 \
  220.         -relheight {} -anchor nw -bordermode ignore 
  221.     menu .vTcl.bind.fra9.men1.m \
  222.          -tearoff 0 
  223.     .vTcl.bind.fra9.men1.m add cascade \
  224.         -label Press -menu .vTcl.bind.fra9.men1.m.press -state normal \
  225.         -underline -1 
  226.     .vTcl.bind.fra9.men1.m add cascade \
  227.         -label Release -menu .vTcl.bind.fra9.men1.m.release -state normal \
  228.         -underline -1 
  229.     .vTcl.bind.fra9.men1.m add command \
  230.         -command {append vTcl(bind,event) "<Motion>"} -label Motion \
  231.         -state normal -underline -1 
  232.     menu .vTcl.bind.fra9.men1.m.press \
  233.          -tearoff 0 
  234.     .vTcl.bind.fra9.men1.m.press add command \
  235.         -command {append vTcl(bind,event) "<Button-1>"} -label 1 \
  236.         -state normal -underline -1 
  237.     .vTcl.bind.fra9.men1.m.press add command \
  238.         -command {append vTcl(bind,event) "<Button-2>"} -label 2 \
  239.         -state normal -underline -1 
  240.     .vTcl.bind.fra9.men1.m.press add command \
  241.         -command {append vTcl(bind,event) "<Button-3>"} -label 3 \
  242.         -state normal -underline -1 
  243.     .vTcl.bind.fra9.men1.m.press add command \
  244.         -command {append vTcl(bind,event) "<Button>"} -label any \
  245.         -state normal -underline -1 
  246.     menu .vTcl.bind.fra9.men1.m.release \
  247.          -tearoff 0 
  248.     .vTcl.bind.fra9.men1.m.release add command \
  249.         -command {append vTcl(bind,event) "<ButtonRelease-1>"} -label 1 \
  250.         -state normal -underline -1 
  251.     .vTcl.bind.fra9.men1.m.release add command \
  252.         -command {append vTcl(bind,event) "<ButtonRelease-2>"} -label 2 \
  253.         -state normal -underline -1 
  254.     .vTcl.bind.fra9.men1.m.release add command \
  255.         -command {append vTcl(bind,event) "<ButtonRelease-3>"} -label 3 \
  256.         -state normal -underline -1 
  257.     .vTcl.bind.fra9.men1.m.release add command \
  258.         -command {append vTcl(bind,event) "<ButtonRelease>"} -label any \
  259.         -state normal -underline -1 
  260.     menubutton .vTcl.bind.fra9.men2 \
  261.         -borderwidth 1 \
  262.          \
  263.         -menu .vTcl.bind.fra9.men2.m -padx 5 -pady 4 -relief raised -text Key 
  264.     place .vTcl.bind.fra9.men2 \
  265.         -x 210 -relx 0 -y 5 -rely 0 -width 60 -relwidth {} -height 20 \
  266.         -relheight {} -anchor nw -bordermode ignore 
  267.     menu .vTcl.bind.fra9.men2.m \
  268.          -tearoff 0 
  269.     .vTcl.bind.fra9.men2.m add command \
  270.         -label Press -state normal -underline -1 -command {
  271.             append vTcl(bind,event) "<KeyPress>"
  272.         }
  273.     .vTcl.bind.fra9.men2.m add command \
  274.         -label Release -state normal -underline -1 -command {
  275.             append vTcl(bind,event) "<KeyRelease>"
  276.         }
  277.     menubutton .vTcl.bind.fra9.men3 \
  278.         -borderwidth 1 \
  279.          -padx 5 \
  280.         -pady 4 -relief raised -text Mod 
  281.     place .vTcl.bind.fra9.men3 \
  282.         -x 275 -relx 0 -y 5 -rely 0 -width 60 -relwidth {} -height 20 \
  283.         -relheight {} -anchor nw -bordermode ignore 
  284.     menubutton .vTcl.bind.fra9.men4 \
  285.         -borderwidth 1 \
  286.          -padx 5 \
  287.         -pady 4 -relief raised -text Window 
  288.     place .vTcl.bind.fra9.men4 \
  289.         -x 340 -relx 0 -y 5 -rely 0 -width 60 -relwidth {} -height 20 \
  290.         -relheight {} -anchor nw -bordermode ignore 
  291. }
  292.